/**
 * @author EmiCam 
 * @version 1
 * @since 15/02/2015
 */

package logica;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class ConexionBD {

	/*** clase para conectar a la base de datos */
	static String bd="pym";
	static String login="root";
	static String passwd="admin";
	static String url="jdbc:mysql://localhost/" + bd;
	
	Connection conn=null;
	public ConexionBD(){
	try{
			Class.forName("com.mysql.jdbc.Driver");
			conn=DriverManager.getConnection(url,login,passwd);
	
		}catch (SQLException e){
			System.out.println(e);
		}catch (ClassNotFoundException e){
			System.out.println(e);
		}
	}	
	
	public ConexionBD(String db){
	try{
			url="jdbc:mysql://localhost/"+db;
			Class.forName("com.mysql.jdbc.Driver");
			conn=DriverManager.getConnection(url,login,passwd);
			
		}catch (SQLException e){
			System.out.println(e);
		}catch (ClassNotFoundException e){
			System.out.println(e);
		}
	}
	
	public Connection getConnection(){
		return conn;
	}
	
	public void desconectar(){
		try {
			conn.close();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public Statement createStatement() {
		// TODO Auto-generated method stub
		return null;
	}	

}
